package com.ayoka.adapter;

import android.graphics.Color;

import com.ayoka.Constant;
import com.ayoka.R;
import com.ayoka.bean.CourseBean;
import com.jcp.baselibrary.brvah.BaseQuickAdapter;
import com.jcp.baselibrary.brvah.BaseViewHolder;
import com.jcp.baselibrary.utils.StringUtil;
import com.jcp.baselibrary.utils.UIUtils;

import java.util.List;

/**
 * Created by jinchunping on 2018/4/11.
 */

public class CoursePackageCourseContentAdapter extends BaseQuickAdapter<CourseBean, BaseViewHolder> {

    public CoursePackageCourseContentAdapter() {
        super(R.layout.item_course_package_course_content, null);
    }

    @Override
    protected void convert(final BaseViewHolder holder, CourseBean item) {
        holder.setText(R.id.tv_course_title, item.Title)
                .setText(R.id.tv_course_learn_count, StringUtil.formatString(R.string.format_learn_count, item.ParticipationTimes))
                .setText(R.id.tv_course_order_number, String.valueOf(item.OrderNum));
        if (item.IsAvailabe == 0) {
            holder.setBackgroundRes(R.id.layout_course_container, R.drawable.bg_course_status_disable)
                    .setEnabled(R.id.tv_course_title, false)
                    .setEnabled(R.id.tv_course_learn_count, false)
                    .setTextColor(R.id.tv_course_order_number, UIUtils.getColor(R.color.gray_9))
                    .setCleanColorFilter(R.id.iv_course_learn_count);
        } else {
            if (item.CourseCompletedStatus == Constant.CourseCompletedStatus.DISABLE) {
                holder.setBackgroundRes(R.id.layout_course_container, R.drawable.bg_course_status_disable)
                        .setEnabled(R.id.tv_course_title, false)
                        .setEnabled(R.id.tv_course_learn_count, false)
                        .setTextColor(R.id.tv_course_order_number, UIUtils.getColor(R.color.gray_9))
                        .setCleanColorFilter(R.id.iv_course_learn_count);
            } else if (item.CourseCompletedStatus == Constant.CourseCompletedStatus.PROCRESSING) {
                holder.setBackgroundRes(R.id.layout_course_container, R.drawable.bg_course_status_process)
                        .setEnabled(R.id.tv_course_title, true)
                        .setEnabled(R.id.tv_course_learn_count, true)
                        .setTextColor(R.id.tv_course_order_number, UIUtils.getColor(R.color.orange_lighter))
                        .setColorFilter(R.id.iv_course_learn_count, Color.BLACK);
            } else {
                holder.setBackgroundRes(R.id.layout_course_container, R.drawable.bg_course_status_completed)
                        .setEnabled(R.id.tv_course_title, true)
                        .setEnabled(R.id.tv_course_learn_count, true)
                        .setTextColor(R.id.tv_course_order_number, UIUtils.getColor(R.color.orange_lighter))
                        .setCleanColorFilter(R.id.iv_course_learn_count);
            }
        }

    }
}
